package com.woniu.adapter;

import com.woniu.outlet.client.WorkingProcedures;
import com.woniu.outlet.dao.WarehousingApplicationMapper;
import com.woniu.outlet.po.WarehousingApplication;
import com.woniu.util.SnowflakeIdGenerator;
import com.woniu.util.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WarehousingAdapter {
    @Autowired
    private WarehousingApplicationMapper warehousingApplicationMapper;
    @Autowired
    private WorkingProcedures workingProcedures;

    public void addWarehousing (WarehousingApplication warehousingApplication) {
        warehousingApplication.setStatus("未入库");
        warehousingApplication.setWarehousingCode("WareApp_"+SnowflakeIdGenerator.nextId());
        warehousingApplication.setWarehousingTime(TimeUtil.getNowDataTime());
        warehousingApplicationMapper.insertSelective(warehousingApplication);
        workingProcedures.addSystemLog("添加入库申请");
    }

    public void updateStatus (Integer id) {
        WarehousingApplication warehousingApplication = new WarehousingApplication();
        warehousingApplication.setId(id);
        warehousingApplication.setStatus("已入库");
        warehousingApplicationMapper.updateByPrimaryKeySelective(warehousingApplication);
        workingProcedures.addSystemLog("修改入库申请状态");
    }
}
